unit u_pesquisapadrao;

interface

uses
  Windows, Messages, SysUtils, Variants, FMTBcd, Graphics, ExtCtrls, Forms,
  AdvGlowButton, Controls, StdCtrls, Grids, DBGrids, JvExDBGrids, JvDBGrid,
  AdvEdit, AdvGroupBox, DB, DBClient, Provider, Classes, SqlExpr;

type
  TFRM_PesquisaPadrao = class(TForm)
    sqlPesquisar: TSQLQuery;
    dspPesquisar: TDataSetProvider;
    cdsPesquisar: TClientDataSet;
    dsPesquisar: TDataSource;
    gbPadrao: TAdvGroupBox;
    edtPesquisar: TAdvEdit;
    GridPesquisar: TJvDBGrid;
    pnlRodape: TPanel;
    lblTotal: TLabel;
    btnConfirmar: TAdvGlowButton;
    btnCancelar: TAdvGlowButton;
    pnlTitulo: TPanel;
    Image2: TImage;
    procedure FormShow(Sender: TObject);
    procedure GridPesquisarDblClick(Sender: TObject);
    procedure GridPesquisarKeyPress(Sender: TObject; var Key: Char);
    procedure edtPesquisarKeyPress(Sender: TObject; var Key: Char);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure GridPesquisarTitleClick(Column: TColumn);
    
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FRM_PesquisaPadrao: TFRM_PesquisaPadrao;

implementation

uses u_dm_geral;

{$R *.dfm}

procedure TFRM_PesquisaPadrao.FormShow(Sender: TObject);
begin
  cdsPesquisar.Open;
  lblTotal.Caption := 'Total: '+ IntToStr(cdsPesquisar.RecordCount);
  GridPesquisar.SetFocus;
end;

procedure TFRM_PesquisaPadrao.GridPesquisarDblClick(Sender: TObject);
begin
  btnConfirmar.Click;
end;

procedure TFRM_PesquisaPadrao.GridPesquisarKeyPress(Sender: TObject;
  var Key: Char);
begin
  if Key = #13 then btnConfirmar.Click;
end;

procedure TFRM_PesquisaPadrao.edtPesquisarKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then btnConfirmar.Click;
end;

procedure TFRM_PesquisaPadrao.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if key = #13 then btnConfirmar.Click;
end;

procedure TFRM_PesquisaPadrao.GridPesquisarTitleClick(Column: TColumn);
var
  i: integer;
begin
  inherited;
  for i:= 0 to GridPesquisar.Columns.Count-1 do GridPesquisar.Columns[i].Title.Font.Style := [];
  TClientDataSet(Column.Grid.DataSource.DataSet).IndexFieldNames := Column.FieldName;
  Column.Title.Font.Style := [fsBold];
end;

end.
